<?php


namespace app\merchant\system\controller;

use app\merchant\system\service\MerConfigService;
use support\exception\BadException;
use support\utils\TenantUtil;

class ConfigController extends BaseController
{
    public function getConfig()
    {
        $key = input('key');
        if (!$key) {
            throw new BadException("参数异常");
        }
        return $this->success(MerConfigService::getConfig(TenantUtil::getTenantId(), $key));
    }

    public function getData()
    {
        $key = input('key');
        if (!$key) {
            throw new BadException("参数异常");
        }
        return $this->success(MerConfigService::getData(TenantUtil::getTenantId(), $key));
    }

    public function setConfig()
    {
        $key = input('key');
        $value = input('value');

        if (!$key) {
            throw new BadException("参数异常");
        }
        MerConfigService::setConfig(TenantUtil::getTenantId(), $key, $value);
        return $this->success();
    }
}